<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <div id="app">
        姓：<input type="text" v-model="firstName" />
        <br/><br/>
        名：<input type="text" v-model="lastName" />
        <br/><br/>
        全名：<span style="color: red; font-size:large;">{{fullName}}</span>
    </div>
    
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    firstName: 'zhang',
                    lastName: 'san'
                }
            },
            computed:{
                // 完整版写法
                /*
                fullName: {
                    get() {
                        return this.firstName + '-' + this.lastName
                    },
                    set(value) {
                        const arr = value.split('-')
                        this.firstName = arr[0]
                        this.lastName = arr[1]
                    }
                }
                */
               // 简写形式
               fullName() {
                    return this.firstName + '-' + this.lastName
               }
            }
        })
    </script>
</body>
</html>